<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        try {

            console.log(a);

        } catch (error) {
            console.log(error);
        }

        console.log("继续运行了");

        // 在平时写程序时遇到有可能出现问题的地方要自己抛出异常随后
        // 去捕获异常方便后续快速解决问题
        function something() {
            let a = 10
            if (a > 10) {
                console.log("执行任务");
            } else {
                throw new Error("a是小于10的程序不能执行")
            }
        }

        try {
             something()
        } catch (error) {
            alert(error)
            
        }
       
    </script>
</body>

</html>